/*
 * @Author: 李佳晶111 11238117+lijiajing-111@user.noreply.gitee.com
 * @Date: 2023-04-07 14:24:56
 * @LastEditors: 李佳晶111 11238117+lijiajing-111@user.noreply.gitee.com
 * @LastEditTime: 2023-04-07 16:10:13
 * @FilePath: \2\shop\src\main.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import { ElMessage } from "element-plus";
import Direc from '@/utils/directive'
import "element-plus/dist/index.css";
import "font-awesome/css/font-awesome.css";

import * as ElementPlusIconsVue from "@element-plus/icons-vue";

const debounce = (fn, delay) => {
  let timer = null;
  return function () {
    let context = this;
    let args = arguments;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  }
}

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver{
  constructor(callback) {
    callback = debounce(callback, 16);
    super(callback);
  }
}


const app = createApp(App);
Direc(app);
app.config.globalProperties.$message = ElMessage;
// element icon 注册
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.use(store).use(router).use(ElementPlus, { locale: zhCn }).mount("#app");
